<template>
	<view>
		<view class="equipment">
			<!-- 设备列表 -->
			<view class="list" v-for="(equ,index) in device" :key="index" @click="shebei(equ.devId)"
				>
				<view class="list_text"><text>{{equ.name}}</text></view>
				<view class="list_text2" v-if="equ.isOnline==true"><text>在线</text></view>
				<view class="list_text2" v-if="equ.isOnline==false"><text>离线</text></view>
				<view class="cus-mian-four"><text>></text></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				homeId: "",
				ShowHidden: false,
				device: [],
				name:""
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			this.homeId = option.homeId;	
			this.name = option.name;
		},
		onShow: function() { //option为object类型，会序列化上个页面传递的参数
			this.getSheBei();
			this.title();
		},
		methods: {
            title(){
				uni.setNavigationBarTitle({
					  title:this.name+"网关列表"
				});
			},
			onNavigationBarButtonTap(ShowHidden) {
				// uni.navigateTo({
				// 	url: '/pages/house/distribution/network?name=' + this.name + '&homeId=' + this.homeId
				// });
				uni.showLoading({
					title: '正在跳转涂鸦智能UI'
				});
				let message="";
				try {
					const deviceConfigModule=uni.requireNativePlugin("LJY-DeviceConfigModule")//调用android中自定义的插件名称
					//执行涂鸦智能登录,使用账户密码登录
					const ret=deviceConfigModule.startDeviceActiveAction({//login表示自定义插件的函数名，第一个表示要传递的参数
					 	homeId: this.homeId
					});
					uni.hideLoading();//加载结束
					message=ret.msg;
					
				}catch (e) {//如果涂鸦智能无法连接
					uni.hideLoading();//加载结束
					message="涂鸦智能家居功能失效"
				}	
				uni.showToast({
					title: message,
					mask: true,
					duration: 2000
				});
			},
			shebei(devId) {
				// console.log(devId)				
				uni.navigateTo({
					url: '/pages/house/equipment/eqList?devId=' + devId + '&name=' + this.name
				});
			},
			getSheBei() {
				try {
					uni.showLoading({
						title: '正在加载设备列表'
					});
					const homeModule = uni.requireNativePlugin("LJY-HomeModule"); //调用android中自定义的插件名称
					const ret = homeModule.homeDetail({ //login表示自定义插件的函数名，第一个表示要传递的参数
						homeId: this.homeId
					});
					// console.log(ret)
					uni.hideLoading(); //加载结束
					if (ret.code == 0) { //加载成功
						this.device = ret.data.deviceList;
						console.log(this.device)
					} else { //加载失败
						uni.showToast({
							title: ret.msg,
							duration: 2000
						});
					}
				} catch (e) { //如果涂鸦智能无法连接
					uni.hideLoading(); //加载结束
					uni.showToast({
						title: '设备列表加载失败,请稍后再试',
					});
				}
			}
		},

	}
</script>


<style lang="less">
	.list {
		width: 100%;
		height: 120rpx;
		/* background-color: #4CD964; */
		border-bottom: 2rpx solid #ebebeb;
		background-color: #FFFFFF;
		align-items: center;
		display: flex;
	}

	.list_text {
		// background-color: #007AFF;
		width: 550rpx;
		margin-top: 10rpx;
	}

	.list_text2 {
		margin-top: 10rpx;
	}

	.list_text text {
		margin-left: 30rpx;
		font-size: 35rpx;
		margin-top: 5rpx;
	}

	.list_text2 text {
		margin-left: 40rpx;
		font-size: 35rpx;
		margin-top: 20rpx;
	}

	.cus-mian-four {
		width: 5%;
		margin-left: 40rpx;
	}

	.cus-mian-four text {
		float: right;
		color: #020202;
		font-size: 60rpx;
		margin-top: 7rpx;
	}

	.arrivalNavigation {
		width: 250rpx;
		position: absolute;
		right: 0rpx;
		top: 20rpx;

		// z-index: 99;

		.sideNavigation {
			width: 230rpx;
			background-color: #C0C0C0;

			border-radius: 10rpx;

			view {
				// height: 85rpx;
				text-align: center;
				line-height: 85rpx;
				font-size: 25rpx;
				list-style-type: none;
				border-bottom: 1rpx solid #ebebeb;
			}



		}


	}
</style>
